/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmDangKy.java
 *
 * Created on 23-05-2011, 00:36:42
 */
package Presentation;

import RSCall.BaoRSc;
import RSCall.ChiTietBaoRSc;
import RSCall.DiaOcRSc;
import RSCall.DuongRSc;
import RSCall.GiaTienQCBangRSc;
import RSCall.GiaTienQCBaoRSc;
import RSCall.GiaTienQCToBuomRSc;
import RSCall.KhachHangRSc;
import RSCall.LoaiDiaOCRSc;
import RSCall.NoiDungRSc;
import RSCall.PhieuDangKyRSc;
import RSCall.PhuongRSc;
import RSCall.QCBangRSc;
import RSCall.QCBaoRSc;
import RSCall.QuanRSc;
import RSCall.ThanhPhoRSc;
import RSCall.ToBuomRSc;
import Entities.BAO;
import Entities.DUONG;
import Entities.GIATIEN_QC_BANG;
import Entities.GIATIEN_QC_BAO;
import Entities.GIATIEN_TOBUOM;
import Entities.KHACHHANG;
import Entities.LOAIDIAOC;
import Entities.PHUONG;
import Entities.QUAN;
import Entities.THANHPHO;
import diaoc.SendMailOK;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import java.sql.Date;
import javax.swing.JRootPane;

/**
 *
 * @author Nixforest
 */
public class frmDangKy extends javax.swing.JInternalFrame{

    private final String thongtinDiaOc = java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("thongTinDiaOc");
    /** Creates new form frmDangKy */
    public frmDangKy(KHACHHANG k) {        
        initComponents();
        Creation();
        khachHang = k;
        MaKH = k.getMaKH();
        // Load một số dữ liệu ban đầu cần thiết
        LoadData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        canvas1 = new java.awt.Canvas();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        cbxLoaiDiaOc = new javax.swing.JComboBox();
        tbxDiaChiCTDiaOc = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        tbxDienTichDat = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tbxDienTichXD = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tbxHuong = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        tbxViTriDiaOc = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        tbxMoTa = new javax.swing.JTextField();
        jLabel35 = new javax.swing.JLabel();
        tbxGiaBan = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        cbxThanhPho = new javax.swing.JComboBox();
        cbxQuan = new javax.swing.JComboBox();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        cbxPhuong = new javax.swing.JComboBox();
        cbxDuong = new javax.swing.JComboBox();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        txtTuNgay = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtDenNgay = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        cbToBuom = new javax.swing.JCheckBox();
        cbQCBao = new javax.swing.JCheckBox();
        cbQCBang = new javax.swing.JCheckBox();
        pnlToBuom = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        cbxSoluong = new javax.swing.JComboBox();
        jLabel30 = new javax.swing.JLabel();
        tbxGiaTien_ToBuom = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        pnlQCBao = new javax.swing.JPanel();
        lblLoaiBao = new javax.swing.JLabel();
        cbxLoaiBao = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        tbxViTriQC = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        tbxGiaTien_QCBao = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAreaGhiChu_QCBao = new javax.swing.JTextArea();
        cbCoHinhAnh = new javax.swing.JCheckBox();
        jLabel23 = new javax.swing.JLabel();
        tbxNgayPhatHanh = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        cbxFormQCBao = new javax.swing.JComboBox();
        jLabel25 = new javax.swing.JLabel();
        tbxMauSac = new javax.swing.JTextField();
        tbxKhoIn = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        pnlLoaiBao = new javax.swing.JPanel();
        jLabel36 = new javax.swing.JLabel();
        tbxNgayBatDau = new javax.swing.JTextField();
        pnlQCBang = new javax.swing.JPanel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        tbxDVT = new javax.swing.JTextField();
        cbxFormQCBang = new javax.swing.JComboBox();
        jLabel27 = new javax.swing.JLabel();
        tbxKichCo = new javax.swing.JTextField();
        jLabel28 = new javax.swing.JLabel();
        tbxGiaTien_QCBang = new javax.swing.JTextField();
        jLabel32 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtAreaMoTa = new javax.swing.JTextArea();
        tbxLoaiBang = new javax.swing.JTextField();
        jLabel29 = new javax.swing.JLabel();
        txtThoiGianHenChupAnh = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtAreaNoiDungQC = new javax.swing.JTextArea();
        btnDangKy = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setClosable(true);
        setTitle(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("titlefrmDangKy"));
        setPreferredSize(new java.awt.Dimension(1080, 630));
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(thongtinDiaOc));

        jLabel5.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("property type"));

        cbxLoaiDiaOc.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel7.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("s1"));

        tbxDienTichDat.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxDienTichDatKeyTyped(evt);
            }
        });

        jLabel8.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("s2"));

        tbxDienTichXD.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxDienTichXDKeyTyped(evt);
            }
        });

        jLabel9.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("direction"));

        jLabel10.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("location"));

        jLabel11.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("describe"));

        jLabel35.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

        tbxGiaBan.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxGiaBanKeyTyped(evt);
            }
        });

        jLabel2.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("address"));

        jLabel33.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("city"));

        jLabel37.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("district"));

        jLabel38.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("precinct"));

        jLabel39.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("street"));

        jLabel40.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("detail"));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel35)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9)
                            .addComponent(jLabel40)
                            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbxViTriDiaOc, javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(tbxGiaBan, javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(tbxMoTa, javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(tbxDiaChiCTDiaOc, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tbxDienTichXD)
                            .addComponent(tbxHuong)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(cbxQuan, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(cbxThanhPho, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(cbxPhuong, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jLabel38)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(cbxDuong, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jLabel39)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbxLoaiDiaOc, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel33)
                                    .addComponent(jLabel37)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbxDienTichDat, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(cbxLoaiDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel33)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbxThanhPho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel37)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbxQuan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel38)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbxPhuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel39)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cbxDuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel40)
                    .addComponent(tbxDiaChiCTDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(tbxDienTichDat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(tbxDienTichXD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(tbxHuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(tbxViTriDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbxGiaBan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel35))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(tbxMoTa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adinfo")));

        jLabel12.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("fromday"));

        jLabel13.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("today"));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adtype"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        cbToBuom.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("handbill"));
        cbToBuom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbToBuomActionPerformed(evt);
            }
        });

        cbQCBao.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adnewspaper"));
        cbQCBao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbQCBaoActionPerformed(evt);
            }
        });

        cbQCBang.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adboard"));
        cbQCBang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbQCBangActionPerformed(evt);
            }
        });

        pnlToBuom.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("handbill")));

        jLabel14.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("quantity"));

        cbxSoluong.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel30.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

        tbxGiaTien_ToBuom.setEditable(false);

        jLabel15.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("VND"));

        javax.swing.GroupLayout pnlToBuomLayout = new javax.swing.GroupLayout(pnlToBuom);
        pnlToBuom.setLayout(pnlToBuomLayout);
        pnlToBuomLayout.setHorizontalGroup(
            pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlToBuomLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlToBuomLayout.createSequentialGroup()
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18))
                    .addGroup(pnlToBuomLayout.createSequentialGroup()
                        .addComponent(jLabel30)
                        .addGap(22, 22, 22)))
                .addGroup(pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbxSoluong, 0, 96, Short.MAX_VALUE)
                    .addComponent(tbxGiaTien_ToBuom))
                .addGap(8, 8, 8)
                .addComponent(jLabel15)
                .addContainerGap())
        );
        pnlToBuomLayout.setVerticalGroup(
            pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlToBuomLayout.createSequentialGroup()
                .addGroup(pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(cbxSoluong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlToBuomLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(tbxGiaTien_ToBuom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlQCBao.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adnewspaper")));

        lblLoaiBao.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("newspaper name"));

        cbxLoaiBao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel16.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("location"));

        tbxViTriQC.setEditable(false);

        jLabel17.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("printsize"));

        jLabel18.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

        tbxGiaTien_QCBao.setEditable(false);

        jLabel19.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("note"));

        txtAreaGhiChu_QCBao.setEditable(false);
        txtAreaGhiChu_QCBao.setColumns(20);
        txtAreaGhiChu_QCBao.setRows(4);
        jScrollPane1.setViewportView(txtAreaGhiChu_QCBao);

        cbCoHinhAnh.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("isHinhAnh"));

        jLabel23.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("publish date"));

        tbxNgayPhatHanh.setEditable(false);

        jLabel24.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adform"));

        cbxFormQCBao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel25.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("color"));

        tbxMauSac.setEditable(false);

        tbxKhoIn.setEditable(false);

        jLabel31.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("VND"));

        pnlLoaiBao.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout pnlLoaiBaoLayout = new javax.swing.GroupLayout(pnlLoaiBao);
        pnlLoaiBao.setLayout(pnlLoaiBaoLayout);
        pnlLoaiBaoLayout.setHorizontalGroup(
            pnlLoaiBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        pnlLoaiBaoLayout.setVerticalGroup(
            pnlLoaiBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jLabel36.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("publish day"));

        javax.swing.GroupLayout pnlQCBaoLayout = new javax.swing.GroupLayout(pnlQCBao);
        pnlQCBao.setLayout(pnlQCBaoLayout);
        pnlQCBaoLayout.setHorizontalGroup(
            pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlQCBaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlQCBaoLayout.createSequentialGroup()
                        .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlQCBaoLayout.createSequentialGroup()
                                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(pnlQCBaoLayout.createSequentialGroup()
                                        .addComponent(jLabel17)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(tbxKhoIn))
                                    .addGroup(pnlQCBaoLayout.createSequentialGroup()
                                        .addComponent(lblLoaiBao)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(cbxLoaiBao, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(38, 38, 38)
                                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel23)
                                    .addComponent(jLabel25)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlQCBaoLayout.createSequentialGroup()
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbxFormQCBao, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(38, 38, 38)
                                .addComponent(jLabel16))
                            .addGroup(pnlQCBaoLayout.createSequentialGroup()
                                .addComponent(jLabel18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tbxGiaTien_QCBao, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel31)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel36)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(25, 25, 25)
                        .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tbxMauSac, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                            .addComponent(tbxViTriQC, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tbxNgayPhatHanh, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tbxNgayBatDau)))
                    .addGroup(pnlQCBaoLayout.createSequentialGroup()
                        .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pnlLoaiBao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbCoHinhAnh))))
                .addContainerGap())
        );
        pnlQCBaoLayout.setVerticalGroup(
            pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlQCBaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblLoaiBao)
                    .addComponent(cbxLoaiBao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23)
                    .addComponent(tbxNgayPhatHanh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbxViTriQC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24)
                    .addComponent(cbxFormQCBao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addGap(18, 18, 18)
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(tbxMauSac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbxKhoIn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addGap(18, 18, 18)
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(tbxGiaTien_QCBao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31)
                    .addComponent(jLabel36)
                    .addComponent(tbxNgayBatDau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(cbCoHinhAnh))
                .addGap(8, 8, 8)
                .addGroup(pnlQCBaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                    .addComponent(pnlLoaiBao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlQCBang.setBorder(javax.swing.BorderFactory.createTitledBorder(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adboard")));

        jLabel20.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adform"));

        jLabel21.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("board"));

        jLabel22.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("unit"));

        tbxDVT.setEditable(false);

        cbxFormQCBang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel27.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("size"));

        tbxKichCo.setEditable(false);

        jLabel28.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

        tbxGiaTien_QCBang.setEditable(false);

        jLabel32.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("VND"));

        jLabel26.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("describe"));

        txtAreaMoTa.setEditable(false);
        txtAreaMoTa.setColumns(20);
        txtAreaMoTa.setLineWrap(true);
        txtAreaMoTa.setRows(2);
        txtAreaMoTa.setWrapStyleWord(true);
        txtAreaMoTa.setAutoscrolls(false);
        jScrollPane2.setViewportView(txtAreaMoTa);

        tbxLoaiBang.setEditable(false);
        tbxLoaiBang.setText("null");

        javax.swing.GroupLayout pnlQCBangLayout = new javax.swing.GroupLayout(pnlQCBang);
        pnlQCBang.setLayout(pnlQCBangLayout);
        pnlQCBangLayout.setHorizontalGroup(
            pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlQCBangLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel27)
                    .addComponent(jLabel28)
                    .addComponent(jLabel26)
                    .addComponent(jLabel22)
                    .addComponent(jLabel20)
                    .addComponent(jLabel21))
                .addGap(30, 30, 30)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tbxDVT)
                    .addComponent(tbxKichCo)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(tbxLoaiBang)
                    .addComponent(cbxFormQCBang, 0, 120, Short.MAX_VALUE)
                    .addComponent(tbxGiaTien_QCBang))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel32)
                .addContainerGap())
        );
        pnlQCBangLayout.setVerticalGroup(
            pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlQCBangLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(cbxFormQCBang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(tbxLoaiBang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel26)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbxDVT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addGap(12, 12, 12)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(tbxKichCo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(12, 12, 12)
                .addGroup(pnlQCBangLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(tbxGiaTien_QCBang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel32))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlQCBao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(cbToBuom)
                        .addGap(18, 18, 18)
                        .addComponent(cbQCBao)
                        .addGap(18, 18, 18)
                        .addComponent(cbQCBang)))
                .addGap(6, 6, 6)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlToBuom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlQCBang, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(pnlToBuom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlQCBang, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbToBuom)
                    .addComponent(cbQCBao)
                    .addComponent(cbQCBang))
                .addGap(18, 18, 18)
                .addComponent(pnlQCBao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jLabel29.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("appointmentday"));

        jLabel34.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adcontent"));

        txtAreaNoiDungQC.setColumns(20);
        txtAreaNoiDungQC.setLineWrap(true);
        txtAreaNoiDungQC.setRows(2);
        txtAreaNoiDungQC.setWrapStyleWord(true);
        txtAreaNoiDungQC.setAutoscrolls(false);
        jScrollPane3.setViewportView(txtAreaNoiDungQC);

        btnDangKy.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("signin"));
        btnDangKy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangKyActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(19, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel12))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtTuNgay)
                                    .addComponent(txtThoiGianHenChupAnh, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDenNgay)))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel34))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnDangKy, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(83, 83, 83))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel12)
                                .addComponent(txtTuNgay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel34, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(17, 17, 17)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13)
                                    .addComponent(txtDenNgay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtThoiGianHenChupAnh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel29)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3))))
                    .addComponent(btnDangKy, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1069, 1069, 1069)
                        .addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Chọn hình thức quảng cáo Tờ Bướm
    private void cbToBuomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbToBuomActionPerformed
        LoadStateHinhThucQC();
    }//GEN-LAST:event_cbToBuomActionPerformed

    // Chọn hình thức quảng cáo Báo
    private void cbQCBaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbQCBaoActionPerformed
        LoadStateHinhThucQC();
    }//GEN-LAST:event_cbQCBaoActionPerformed

    // Chọn hình thức quảng cáo Bảng
    private void cbQCBangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbQCBangActionPerformed
        LoadStateHinhThucQC();
    }//GEN-LAST:event_cbQCBangActionPerformed

    // Kiểm tra xem khách hàng cũ hay mới
    // Xử lý đăng ký
    private void btnDangKyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangKyActionPerformed
        // Kiểm tra các điều kiện ràng buộc
        if (CheckDiaOc() && CheckNoiDungQC() && CheckPhieuDangKy() && CheckQuangCao()) {            
            // Xử lý đăng ký Khách hàng
            if (!MaKH.equals("")) { //NOI18N
                try {
                    MaKH = dbKhachHang.Update(khachHang.getMaKH(), khachHang.getHoTen(),
                            khachHang.getDiaChiKH().getMaThanhPho(),
                            khachHang.getDiaChiKH().getMaQuan(),
                            khachHang.getDiaChiKH().getMaPhuong(),
                            khachHang.getDiaChiKH().getMaDuong(),
                            khachHang.getDiaChiKH().getDiaChiCT(),
                            khachHang.getSoDT(), khachHang.getEmail());
                }catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
                
            }else{
                try {
                    MaKH = dbKhachHang.Insert(khachHang.getHoTen(),
                            khachHang.getDiaChiKH().getMaThanhPho(),
                            khachHang.getDiaChiKH().getMaQuan(),
                            khachHang.getDiaChiKH().getMaPhuong(),
                            khachHang.getDiaChiKH().getMaDuong(),
                            khachHang.getDiaChiKH().getDiaChiCT(),
                            khachHang.getSoDT(), khachHang.getEmail());
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
            }
            
            // Xử lý đăng ký Địa ốc
            String maLoaiDiaOc = ((LOAIDIAOC)cbxLoaiDiaOc.getSelectedItem()).getMaLoaiDiaOc();
            String maThanhPho = ((THANHPHO)cbxThanhPho.getSelectedItem()).getMaThanhPho();
            String maQuan = ((QUAN)cbxQuan.getSelectedItem()).getMaQuan();
            String maPhuong = ((PHUONG)cbxPhuong.getSelectedItem()).getMaPhuong();
            String maDuong = ((DUONG)cbxDuong.getSelectedItem()).getMaDuong();
            String diaChiDO = tbxDiaChiCTDiaOc.getText().trim();
            Float dienTichDat = Float.parseFloat(tbxDienTichDat.getText().trim());
            Float dienTichXD = Float.parseFloat(tbxDienTichXD.getText().trim());
            String huong = tbxHuong.getText().trim();
            String viTriDO = tbxViTriDiaOc.getText().trim();
            String moTa = tbxMoTa.getText().trim();
            String trangThai = "Chưa bán";
            Float giaBan = Float.parseFloat(tbxGiaBan.getText().trim());
            try{
                MaDiaOc = dbDiaOc.Insert(maLoaiDiaOc, maThanhPho, maQuan, maPhuong,
                        maDuong, diaChiDO, dienTichDat, dienTichXD, huong, viTriDO,
                        moTa, trangThai, giaBan);
            }catch(Exception ex){
                JOptionPane.showMessageDialog(this, ex.toString());
            }
            
            
            // Xử lý đăng ký Nội dung quảng cáo
            String thongTinDiaOc = txtAreaNoiDungQC.getText().trim();
            String moTaTomTat = java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost") +" "+ tbxGiaBan.getText().trim();
            try{
                MaND = dbNoiDung.Insert(thongTinDiaOc, moTaTomTat);
            }catch(Exception ex){
                JOptionPane.showMessageDialog(this, ex.toString());
            }
            
            
            // Xử lý Tạo mới Phiếu đăng ký
            Date tuNgay = Date.valueOf(txtTuNgay.getText());
            Date denNgay = Date.valueOf(txtDenNgay.getText());
            Float soTien = 0.0f;
            if (cbToBuom.isSelected()) {
                soTien += Float.parseFloat(tbxGiaTien_ToBuom.getText());
            }
            if (cbQCBao.isSelected()) {
                soTien += Float.parseFloat(tbxGiaTien_QCBao.getText()) * listBao.size();
            }
            if (cbQCBang.isSelected()) {
                soTien += Float.parseFloat(tbxGiaTien_QCBang.getText());
            }
            Date thoiGianHenChupAnh = Date.valueOf(txtThoiGianHenChupAnh.getText().trim());
            long d = (denNgay.getTime() - tuNgay.getTime())/(24*3600*1000);
            soTien += (d+1)*3000;
            try{
                MaPhieuDK = dbPhieuDangKy.Insert(MaDiaOc, tuNgay, denNgay, soTien, thoiGianHenChupAnh, MaKH);
            }catch(Exception ex){
                JOptionPane.showMessageDialog(this, ex.toString());
            }
            
            // Xử lý đăng ký các Hình thức quảng cáo
            if (cbToBuom.isSelected()) {                            // Tạo mới Tờ bướm
                String s = cbxSoluong.getSelectedItem().toString();
                String maGiaTien = "";
                try {
                    maGiaTien = giaToBuom.GetIDBySoLuong(Integer.parseInt(s));
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
                try {
                    dbToBuom.Insert(MaND, MaPhieuDK, maGiaTien);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
            }
            if (cbQCBao.isSelected()) {                             // Tạo mới Quảng cáo Báo
                Date ngayBatDauPhatHanh = Date.valueOf(tbxNgayBatDau.getText().trim());
                Boolean coHinhAnh = cbCoHinhAnh.isSelected();
                String maGiaTien = cbxFormQCBao.getSelectedItem().toString();
                try {
                    MaQCBao = dbQCBao.Insert(ngayBatDauPhatHanh, coHinhAnh, MaND, MaPhieuDK, maGiaTien);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
                
                // Tạo các Chi tiết Báo
                for(String s : listBao){
                    String maBao = s;
                    try {
                        dbChiTietBao.Insert(MaQCBao, maBao);
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(this, ex.toString());
                    }
                }
            }
            if (cbQCBang.isSelected()) {                            // Tạo mới Quảng cáo Bảng
                String maGiaTien = cbxFormQCBang.getSelectedItem().toString();
                try {
                    dbQCBang.Insert(MaND, MaPhieuDK, maGiaTien);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, ex.toString());
                }
            }
            
            // Đăng ký đã thành công
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("signinsuccess"));
            try {
                SendMailOK.send(SendMailOK.Server, khachHang.getEmail(),
                        SendMailOK.companyMail, SendMailOK.companyMailPass,
                        "Đăng ký rao bán địa ốc tại Chợ Địa ốc A & Q",
                        "Bạn vừa mới đăng ký rao bán địa ốc tại Chợ Địa ốc A & Q!");
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.toString());
                Logger.getLogger(frmDangKy.class.getName()).log(Level.SEVERE, null, ex);
            }
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("sendedCustomer"));
            this.dispose();
        }
//        else JOptionPane.showMessageDialog(this,
//                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("signinfail"));
    }//GEN-LAST:event_btnDangKyActionPerformed

    private void tbxGiaBanKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxGiaBanKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxGiaBanKeyTyped

    private void tbxDienTichDatKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxDienTichDatKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxDienTichDatKeyTyped

    private void tbxDienTichXDKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxDienTichXDKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxDienTichXDKeyTyped

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        JRootPane rootPane = this.getRootPane();
        rootPane.setDefaultButton(btnDangKy);
    }//GEN-LAST:event_formInternalFrameOpened

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDangKy;
    private java.awt.Canvas canvas1;
    private javax.swing.JCheckBox cbCoHinhAnh;
    private javax.swing.JCheckBox cbQCBang;
    private javax.swing.JCheckBox cbQCBao;
    private javax.swing.JCheckBox cbToBuom;
    private javax.swing.JComboBox cbxDuong;
    private javax.swing.JComboBox cbxFormQCBang;
    private javax.swing.JComboBox cbxFormQCBao;
    private javax.swing.JComboBox cbxLoaiBao;
    private javax.swing.JComboBox cbxLoaiDiaOc;
    private javax.swing.JComboBox cbxPhuong;
    private javax.swing.JComboBox cbxQuan;
    private javax.swing.JComboBox cbxSoluong;
    private javax.swing.JComboBox cbxThanhPho;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel lblLoaiBao;
    private javax.swing.JPanel pnlLoaiBao;
    private javax.swing.JPanel pnlQCBang;
    private javax.swing.JPanel pnlQCBao;
    private javax.swing.JPanel pnlToBuom;
    private javax.swing.JTextField tbxDVT;
    private javax.swing.JTextField tbxDiaChiCTDiaOc;
    private javax.swing.JTextField tbxDienTichDat;
    private javax.swing.JTextField tbxDienTichXD;
    private javax.swing.JTextField tbxGiaBan;
    private javax.swing.JTextField tbxGiaTien_QCBang;
    private javax.swing.JTextField tbxGiaTien_QCBao;
    private javax.swing.JTextField tbxGiaTien_ToBuom;
    private javax.swing.JTextField tbxHuong;
    private javax.swing.JTextField tbxKhoIn;
    private javax.swing.JTextField tbxKichCo;
    private javax.swing.JTextField tbxLoaiBang;
    private javax.swing.JTextField tbxMauSac;
    private javax.swing.JTextField tbxMoTa;
    private javax.swing.JTextField tbxNgayBatDau;
    private javax.swing.JTextField tbxNgayPhatHanh;
    private javax.swing.JTextField tbxViTriDiaOc;
    private javax.swing.JTextField tbxViTriQC;
    private javax.swing.JTextArea txtAreaGhiChu_QCBao;
    private javax.swing.JTextArea txtAreaMoTa;
    private javax.swing.JTextArea txtAreaNoiDungQC;
    private javax.swing.JTextField txtDenNgay;
    private javax.swing.JTextField txtThoiGianHenChupAnh;
    private javax.swing.JTextField txtTuNgay;
    // End of variables declaration//GEN-END:variables
    
    private String MaKH;
    private String MaDiaOc;
    private String MaND;
    private String MaPhieuDK;
    private String MaQCBao;
    private Entities.KHACHHANG khachHang;
    
    // Các Table gốc
    private GiaTienQCToBuomRSc giaToBuom;
    private BaoRSc loaiBao;
    private RSCall.GiaTienQCBaoRSc giaQCBao;
    private RSCall.GiaTienQCBangRSc giaQCBang;
    private LoaiDiaOCRSc loaiDiaOc;
    private RSCall.ThanhPhoRSc dbThanhPho;
    private RSCall.QuanRSc dbQuan;
    private RSCall.PhuongRSc dbPhuong;
    private RSCall.DuongRSc dbDuong;

    // Các table cần thêm mới
    private RSCall.KhachHangRSc dbKhachHang;
    private RSCall.DiaOcRSc dbDiaOc;
    private RSCall.NoiDungRSc dbNoiDung;
    private RSCall.PhieuDangKyRSc dbPhieuDangKy;
    private RSCall.ToBuomRSc dbToBuom;
    private RSCall.QCBaoRSc dbQCBao;
    private RSCall.ChiTietBaoRSc dbChiTietBao;
    private RSCall.QCBangRSc dbQCBang;

    private ArrayList<String> listBao;                        // Quản lý các Loại báo

    private void Creation(){
        try{
            khachHang = new KHACHHANG();
            dbThanhPho = new ThanhPhoRSc();
            dbQuan = new QuanRSc();
            dbPhuong = new PhuongRSc();
            dbDuong = new DuongRSc();
            dbNoiDung = new NoiDungRSc();
            dbPhieuDangKy = new PhieuDangKyRSc();
            dbToBuom = new ToBuomRSc();        
            dbQCBao = new QCBaoRSc();
            dbChiTietBao = new ChiTietBaoRSc();
            dbQCBang = new QCBangRSc();
            dbKhachHang = new KhachHangRSc();
            dbDiaOc = new DiaOcRSc();
            loaiDiaOc = new LoaiDiaOCRSc();
            giaToBuom = new GiaTienQCToBuomRSc();
            loaiBao = new BaoRSc();
            giaQCBao = new GiaTienQCBaoRSc();
            giaQCBang = new GiaTienQCBangRSc();
        }catch(Exception e){
         Logger.getLogger(frmDangKy.class.getName()).log(Level.SEVERE, null, e);
        }
    }
     
    // Load dữ liệu cho form
    private void LoadData(){
        for(THANHPHO t : dbThanhPho.mainList){
            cbxThanhPho.addItem(t);
        }
        for(QUAN q : dbQuan.mainList){
            cbxQuan.addItem(q);
        }
        
        for(PHUONG p : dbPhuong.mainList){
            cbxPhuong.addItem(p);
        }
        for(DUONG d : dbDuong.mainList){
            cbxDuong.addItem(d);
        }
        // Tạo dữ liệu cho Loại địa ốc
        cbxLoaiDiaOc.removeAllItems();
        for(LOAIDIAOC l : loaiDiaOc.mainList){
            cbxLoaiDiaOc.addItem(l);
        }
        
        // Tạo dữ liệu cho trường Số lượng
        cbxSoluong.removeAllItems();
        cbxSoluong.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                GIATIEN_TOBUOM g = (GIATIEN_TOBUOM)cbxSoluong.getSelectedItem();
                tbxGiaTien_ToBuom.setText(Float.toString(g.getGiaTien()));
            }
        });
        for(GIATIEN_TOBUOM g : giaToBuom.mainList){
            cbxSoluong.addItem(g);
        }
        
        // Tạo dữ liệu cho trường Loại báo
        cbxLoaiBao.removeAllItems();
        cbxLoaiBao.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                BAO b = (BAO)cbxLoaiBao.getSelectedItem();
                tbxNgayPhatHanh.setText(Utilities.Utilities.GetThu(b.getThuPhatHanh()));
            }
        });
        for(BAO b : loaiBao.mainList){
            cbxLoaiBao.addItem(b);
        }
        
        // Tạo dữ liệu cho trường Form quảng cáo Báo
        cbxFormQCBao.removeAllItems();
        cbxFormQCBao.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                GIATIEN_QC_BAO g = (GIATIEN_QC_BAO)cbxFormQCBao.getSelectedItem();
                tbxViTriQC.setText(g.getViTri());
                tbxKhoIn.setText(g.getKhoIn());
                tbxMauSac.setText(g.getMauSac());
                txtAreaGhiChu_QCBao.setText(g.getGhiChu());
                tbxGiaTien_QCBao.setText(g.getGiaTien().toString());
            }
        });
        for(Entities.GIATIEN_QC_BAO g : giaQCBao.mainList){
            cbxFormQCBao.addItem(g);
        }
        
        // Tạo dữ liệu cho mục chọn các loại báo
        pnlLoaiBao.setLayout(new GridLayout(loaiBao.mainList.size(), 1));
        pnlLoaiBao.setPreferredSize(new Dimension(200, 130));
        pnlLoaiBao.setMinimumSize(pnlLoaiBao.getPreferredSize());
        pnlLoaiBao.setMaximumSize(pnlLoaiBao.getPreferredSize());
        listBao = new ArrayList<String>();
        for(BAO b : loaiBao.mainList){
            JCheckBox c = new JCheckBox(b.getTenBao());
            c.setText(b.getTenBao());
            c.setName(b.getMaBao());
            c.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JCheckBox cb = (JCheckBox)e.getSource();
                    if (cb.isSelected()) {
                        if (listBao.indexOf(cb.getName()) == -1) {
                            listBao.add(cb.getName());
                        }
                    }
                    else{
                        listBao.remove(listBao.indexOf(cb.getName()));
                    }
                }
            });
            pnlLoaiBao.add(c);
        }
        
        // Tạo dữ liệu cho trường Form quảng cáo bảng
        cbxFormQCBang.removeAllItems();
        cbxFormQCBang.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                GIATIEN_QC_BANG g = (GIATIEN_QC_BANG)cbxFormQCBang.getSelectedItem();
                try{
                    tbxLoaiBang.setText(giaQCBang.GetLoaiBang(g.getMaLoaiBang()));
                    txtAreaMoTa.setText(g.getMoTa());
                    tbxKichCo.setText(g.getKichCo().toString());
                    tbxDVT.setText(g.getDVT());
                    tbxGiaTien_QCBang.setText(g.getGiaTien().toString());
                }catch(Exception ex){                    
                    JOptionPane.showMessageDialog(rootPane, ex.toString());
                }
            }
        });
        for(Entities.GIATIEN_QC_BANG g : giaQCBang.mainList){
            cbxFormQCBang.addItem(g);
        }
        
        // Tạo sự lựa chọn mặc định cho hình thức quảng cáo
        cbToBuom.setSelected(true);
        LoadStateHinhThucQC();
    }
    
    // Tạo trạng thái ban đầu cho mỗi hình thức quảng cáo
    private void LoadStateHinhThucQC(){
        Utilities.Utilities.setEnabledForAll(pnlToBuom, cbToBuom.isSelected());
        Utilities.Utilities.setEnabledForAll(pnlQCBao, cbQCBao.isSelected());
        Utilities.Utilities.setEnabledForAll(pnlQCBang, cbQCBang.isSelected());
    }
    
    // Kiểm tra các dữ liệu cần thiết để đăng ký địa ốc
    private boolean CheckDiaOc(){
        String diaChi = tbxDiaChiCTDiaOc.getText();
        String dienTichDat = tbxDienTichDat.getText();
        String dienTichXD = tbxDienTichXD.getText();
        String huong = tbxHuong.getText();
        String viTri = tbxViTriDiaOc.getText();
        String moTa = tbxMoTa.getText();
        String giaBan = tbxGiaBan.getText();
        if (diaChi.trim().isEmpty()) {
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenteraddressproperty"));
        }else if(dienTichDat.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters1property"));
        }else if(dienTichXD.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters2property"));
        }else if(huong.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdirectionproperty"));
        }else if(viTri.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterlocationproperty"));
        }else if(moTa.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdescribeproperty"));
        }else if(giaBan.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notentercostproperty"));
        }else{
            try{
                Float d1 = Float.parseFloat(dienTichDat.trim());
                Float d2 = Float.parseFloat(dienTichXD.trim());
                Float g = Float.parseFloat(giaBan.trim());
                if(d1 > 0 && d2 > 0 && g > 0)
                    return true;
                else JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("conditionnumber"));
            }catch(NumberFormatException e){
                JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("validnumber"));
            }
        }
        return false;
    }
    
    // Kiểm tra các dữ liệu cần thiết để đăng ký Nội dung quảng cáo
    private boolean CheckNoiDungQC(){
        String thongTinDiaOc = txtAreaNoiDungQC.getText();
        if (thongTinDiaOc.trim().isEmpty()) {
            JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustenterndqc"));
        }else{
            return true;
        }
        return false;
    }
    
    // Kiểm tra các dữ liệu cần thiết để đăng ký các hình thức quảng cáo
    private boolean CheckQuangCao(){
        // Xử lý đăng ký quảng cáo bằng Báo
        if (cbQCBao.isSelected()) {
            String ngayBDPH = tbxNgayBatDau.getText();
            if (ngayBDPH.trim().isEmpty()) {
                JOptionPane.showMessageDialog(this,
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustenterpublishday"));
            }else{
                try{
                    Date d = Date.valueOf(ngayBDPH.trim());
                    return true;
                }catch(IllegalArgumentException e){
                    JOptionPane.showMessageDialog(this,
                        java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("dateform"));
                }
            }
            return false;
        }else return true;
    }
    
    // Kiểm tra các dữ liệu cần thiết để tạo mới phiếu đăng ký
    private boolean CheckPhieuDangKy(){
        String tuNgay = txtTuNgay.getText();
        String denNgay = txtDenNgay.getText();
        String thoiGianHenChupAnh = txtThoiGianHenChupAnh.getText();
        if (tuNgay.trim().isEmpty()) {
            JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustenterfromday"));
        }else if(denNgay.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustentertoday"));
        }else if(thoiGianHenChupAnh.trim().isEmpty()){
            JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustenterngayhen"));
        }else{
            try{
                java.sql.Date d1 = java.sql.Date.valueOf(tuNgay.trim());
                java.sql.Date d2 = java.sql.Date.valueOf(denNgay.trim());
                java.sql.Date d3 = java.sql.Date.valueOf(thoiGianHenChupAnh.trim());
                if (d2.compareTo(d1) != -1) {
                    return true;
                }else JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("validdate"));
            }catch(IllegalArgumentException e){
                JOptionPane.showMessageDialog(this,
                java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("dateform"));
            }
        }
        return false;
    }
}
